<template>
  <div class="c-ph24">
    <div class="c-pt210 c-flex-row c-flex-center">
      <img class="c-ww220" src="../../../assets/i/wap/qa/invite_friend.png" alt=" /">
    </div>
    <div class="c-ph24 c-pt60 c-textAlign-c c-fs28">点击右上角“...”分享好友，邀请好友成为{{questionCustom == 1 ? '光之管道' : '答主'}}，此链接120分钟内有效</div>

  </div>
</template>

<script>
import { utilJs } from "@/utils/common.js";
let shareData = null;
export default {
  name: "InviteFriend",
  components: {},
  props: [],
  beforeCreate() { },
  data() {
    return {
      theme: localStorage.getItem("colorName")
        ? localStorage.getItem("colorName")
        : "mb5_default",
      questionCustom: localStorage.getItem("questionCustom"), //定制阿卡西线上学院
      questionInfo: JSON.parse(localStorage.getItem("questionInfo")),
      dataInfo: "",
      lecturerId: '',
    };
  },
  created() {
    utilJs.appShare(this);
  },
  mounted() { },
  computed: {},
  watch: {},
  methods: {
    //获取分享信息
    getShareInfo() {
      utilJs.getMethod(global.apiurl + "question/getQuestionInfo", res => {
        if (res.validity == -1) {
          this.$routerGo(this, "replace", {
            path: "/error/emptyPage",
            query: { from: "qa", info: "该链接已失效" }
          });
          return;
        }
        let title = this.questionCustom == 1 ? this.questionInfo.readerTitle : res.title;
        let shareDesc = this.questionCustom == 1 ? this.questionInfo.readerDescribe : res.describe;
        let shareUrl = `${window.location.href.split("#")[0]}#/homePage/qa/inviteLord?lecturerId=${this.lecturerId}&refereeId=${localStorage.getItem("userId")}`;
        let shareImg = res.cover;
        shareData = {
          title: title,
          shareDesc: shareDesc,
          shareUrl: shareUrl,
          shareImg: shareImg,
        }
        utilJs.wechatConfig(
          shareUrl,
          title,
          shareImg,
          shareDesc,
          function () { }
        );
      });
    },
    //手机端分享
    appShare() {
      utilJs.appShareTrue(
        shareData.title,
        shareData.shareImg,
        shareData.shareUrl,
        shareData.shareDesc
      );
    }

  },
  activated() {
    setDocumentTitle("邀请好友");// eslint-disable-line
    this.lecturerId = this.$route.query.lecturerId || '';
    this.getShareInfo();
  },
  deactivated() { }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
